-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add unregister nano contract saga effect [10] #457
Conversation
432ff49
to
553f87b
Compare
674669c
to
a369c8c
Compare
2c4494b
to
cbd98be
Compare
a369c8c
to
eea421e
Compare
cbd98be
to
e1d912d
Compare
eea421e
to
0c153f2
Compare
e5fdf24
to
a56f2fc
Compare
async unregisterNanoContract(ncId) { | ||
await super.unregisterNanoContract(ncId); | ||
const contracts = STORE.getItem(REGISTERED_NANO_CONTRACTS_KEY) || {}; | ||
delete contracts[ncId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to set the new object to STORE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't. There aren't a new object to set, contracts
is a reference to the object, and we only need remove an entry from this object to set it right. Unless we want to work with immutable objects, which is not the case here. The unregisterToken
method sets the registerTokens
object after delete, but this operation is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that the STORE allows us to mutate its stored object directly, but I don't like the idea of potentially multiple places mutating the object directly, I think we should indeed use immutable objects
My suggestion is that we avoid mutating the object in this PR, use STORE.setItem
to store it even though it's redundant and open a KTLO to return immutable objects in the Storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree we should do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is that we avoid mutating the object in this PR, use STORE.setItem to store it even though it's redundant and open a KTLO to return immutable objects in the Storage
Ok. I will open a PR. However, to achieve immutability we need more than just use the spread operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, we can discuss this in the KTLO, but at the very least we should return a new instance of the object, to prevent the stored object from being mutated by the api consumer
fix: docstring fix: registerNanoContract test fix: historyNanoContract test feat: remove registered nano contracts on cleanTokens feat: add unregisterNanoContract to HybridStore review: apply suggestions and do some tweaks
a56f2fc
to
083f44e
Compare
async unregisterNanoContract(ncId) { | ||
await super.unregisterNanoContract(ncId); | ||
const contracts = STORE.getItem(REGISTERED_NANO_CONTRACTS_KEY) || {}; | ||
delete contracts[ncId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that the STORE allows us to mutate its stored object directly, but I don't like the idea of potentially multiple places mutating the object directly, I think we should indeed use immutable objects
My suggestion is that we avoid mutating the object in this PR, use STORE.setItem
to store it even though it's redundant and open a KTLO to return immutable objects in the Storage
src/sagas/nanoContract.js
Outdated
|
||
const wallet = yield select((state) => state.wallet); | ||
if (!wallet.isReady()) { | ||
log.debug('Fail unregistering Nano Contract because wallet is not ready yet.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use log.error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we shouldn't because there was no error, it is just a condition we don't tolerate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an exception, we even yield a fatal error to sentry
src/sagas/nanoContract.js
Outdated
|
||
const wallet = yield select((state) => state.wallet); | ||
if (!wallet.isReady()) { | ||
log.debug('Fail unregistering Nano Contract because wallet is not ready yet.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an exception, we even yield a fatal error to sentry
* feat(nc): implement unregister nano contract saga effect * feat: remove registered nano contracts on cleanTokens * feat: add unregisterNanoContract to HybridStore
Motivation
This is a PR on a sequence to make the review easier.
Acceptance Criteria
nanoContractAddressChangeRequest
actiononNanoContractAddressChangeRequest
Note
It depends on:
Security Checklist